package car.aistar.service.Impl.xrb;

import car.aistar.dto.CarOverview;
import car.aistar.dto.LaoxuPersonDto;
import car.aistar.dto.PriceCutXu;
import car.aistar.dto.XrbRecent;
import car.aistar.service.CarOverviewService;
import car.aistar.service.LaoxuPersonService;
import car.aistar.service.PersonCenterService;
import com.github.pagehelper.PageInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

/**
 * @ClassName testCarOverview
 * @Description TODO
 * @Author laoxu
 * @Date 2020/10/2 13:54
 * Version 1.0
 **/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring/spring-*.xml")
public class testCarOverview {
    @Autowired
    private CarOverviewService carOverviewService;

    @Autowired
    private LaoxuPersonService laoxuPersonService;

    @Autowired
    private PersonCenterService personCenterService;

    @Test
    public void testCarOverview(){
        List<CarOverview> carOverviewsList = carOverviewService.queryOverview(93L);
        for (CarOverview cov : carOverviewsList) {
            System.out.println(cov.getBrName());
        }
    }

    @Test
    public void testCarCollect(){
        List<CarOverview> carOverviewList = carOverviewService.queryCollect(88L);
        System.out.println(carOverviewList);
        for (CarOverview carOverview : carOverviewList) {
            System.out.println(carOverview.getBrName());
        }
    }

    @Test
    public void testCollectPage(){
        PageInfo<CarOverview> pageInfo = carOverviewService.findCollectPage(88L,"2","6");
        System.out.println(pageInfo.getPages());

        System.out.println(pageInfo.getPageNum());
        System.out.println(pageInfo.getSize());

        pageInfo.getList().forEach(e-> System.out.println(e));
    }

    @Test
    public void testOverview(){
        PageInfo<CarOverview> pageInfo = carOverviewService.findByPage1(93L,"1","5");
        System.out.println(pageInfo.getPages());

        System.out.println(pageInfo.getPageNum());
        System.out.println(pageInfo.getSize());

        pageInfo.getList().forEach(e-> System.out.println(e));
    }

    @Test
    public void testNew(){
        List<XrbRecent> xrbRecentList = carOverviewService.queryRecent();

        for (XrbRecent recent : xrbRecentList) {
            System.out.println(recent.getRePrice());
            System.out.println(recent.getBrName());
        }
    }

    @Test
    public void testPriceCut(){
        Long uid = 1L;
        List<PriceCutXu> priceCutXuList = carOverviewService.queryPriceCut(uid);
        for (PriceCutXu xu : priceCutXuList) {
            System.out.println(xu.getCutPrice());
        }
    }

    @Test
    public void testHistory(){

        Long uid = 88L;
//        List<LaoxuPersonDto> carOverviewList = laoxuPersonService.queryByHistory(uid);
        PageInfo<CarOverview> pageInfo = laoxuPersonService.queryPageHistory(uid,3,5);

        System.out.println(pageInfo.getPages());

        System.out.println(pageInfo.getPageNum());
        System.out.println(pageInfo.getSize());
        pageInfo.getList().forEach(e-> System.out.println(e));

    }
}
